package com.duing.controller;

import com.duing.service.BookService;
import com.duing.vo.BookVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
public class BookController {

    @Autowired
    private BookService bookService;

    @GetMapping("/index")
    public String index() {
        return "index";
    }

    @GetMapping("/book/search")
    public String search(@RequestParam("keyword") String keyword, Model model){
        System.out.println(keyword);
        List<BookVo> bookVos = bookService.selectByName(keyword);
        System.out.println(bookVos);
        model.addAttribute("bookVos",bookVos);
        return "booklist";
    }

    @GetMapping("/book/toDetail")
    public String detail(@RequestParam("bookId") String bookId, Model model){
        return "bookDetail";
    }

}
